package com.eep.logging;

import com.eep.data.DataService;
import com.eep.data.DataServiceImpl;
import com.eep.data.DatabaseName;
import java.util.List;

/**
 *
 * @author Brian Laick
 */
public class LoggingServiceImpl implements LoggingService
{
    private DataService dataService = null;
    
    public LoggingServiceImpl ()
    {
        dataService = new DataServiceImpl();
       
    }
    public void logAppEvent(LogEvent appEvent)
    {
        if(appEvent.getLogType().matches(LogType.Security.getLogDescription()))
        {
            dataService.createConnection(DatabaseName.Security);
        }
        else
        {
            dataService.createConnection(DatabaseName.OrderInfo);
        }
        dataService.createLogItem(appEvent);
    }

    public List<LogEvent> retrieveLog(LogType logType)
    {
        if(logType == LogType.Security)
        {
            dataService.createConnection(DatabaseName.Security);
        }
        else
        {
            dataService.createConnection(DatabaseName.OrderInfo);
        }

        return dataService.listLog(logType);
    }
}
